import 'dart:convert' show json;

T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }

  return null;
}

class MineAddressBean {
  MineAddressBean({
    this.code,
    this.data,
  });

  factory MineAddressBean.fromJson(Map<String, dynamic> jsonRes) =>
      jsonRes == null
          ? null
          : MineAddressBean(
              code: asT<int>(jsonRes['code']),
              data: Data.fromJson(asT<Map<String, dynamic>>(jsonRes['data'])),
            );

  int code;
  Data data;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'code': code,
        'data': data,
      };

  @override
  String toString() {
    return json.encode(this);
  }
}

class Data {
  Data({
    this.results,
  });

  factory Data.fromJson(Map<String, dynamic> jsonRes) {
    if (jsonRes == null) {
      return null;
    }

    final List<MineAddress> results =
        jsonRes['results'] is List ? <MineAddress>[] : null;
    if (results != null) {
      for (final dynamic item in jsonRes['results']) {
        if (item != null) {
          results.add(MineAddress.fromJson(asT<Map<String, dynamic>>(item)));
        }
      }
    }
    return Data(
      results: results,
    );
  }

  List<MineAddress> results;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'results': results,
      };

  @override
  String toString() {
    return json.encode(this);
  }
}

class MineAddress {
  MineAddress({
    this.id,
    this.signer_name,
    this.signer_mobile,
    this.signer_sex,
    this.province,
    this.city,
    this.district,
    this.address,
  });

  factory MineAddress.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : MineAddress(
          id: asT<int>(jsonRes['id']),
          signer_name: asT<String>(jsonRes['signer_name']),
          signer_mobile: asT<String>(jsonRes['signer_mobile']),
          signer_sex: asT<String>(jsonRes['signer_sex']),
          province: asT<String>(jsonRes['province']),
          city: asT<String>(jsonRes['city']),
          district: asT<String>(jsonRes['district']),
          address: asT<String>(jsonRes['address']),
        );

  int id;
  String signer_name;
  String signer_mobile;
  String signer_sex;
  String province;
  String city;
  String district;
  String address;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'id': id,
        'signer_name': signer_name,
        'signer_mobile': signer_mobile,
        'signer_sex': signer_sex,
        'province': province,
        'city': city,
        'district': district,
        'address': address,
      };

  @override
  String toString() {
    return json.encode(this);
  }
}
